home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: extern func() declaration?
- Date: Fri, 05 Apr 96 14:49:05 GMT
- Organization: none
- Message-ID: <828715745snz@genesis.demon.co.uk>
- References: <316436C5.413E@micromedia.on.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <316436C5.413E@micromedia.on.ca>
- rsteadma@micromedia.on.ca "Richard Steadman" writes:
-
- >Hello. This is just a minor point, but I couldn't find the
- >answer in the FAQ:
- >
- >What's the difference between
- >
- > extern int func(void);
- >
- >and
- >
- > int func(void);
-
- There is no difference at all. A function declaration defaults to external
- linkage unless you explicitly make it static so whether you use extern
- or not is simply a style issue. extern can make a difference when declaring
- objects rather then functions e.g. if you write:
-
- int i;
-
- then i is guaranteed to be defined (i.e. space allocated), barring errors
- elsewhere, in the current translation unit whereas if you write:
-
- extern int i;
-
- there is no such guarantee either way. There is nothing equivalent for
- functions because a function is defined whenever you give it a body e.g.
-
- extern int main(void)
-
- {
- return 0;
- }
-
- is a perfectly good definition of main.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-